#include <iostream>
using std::cout;
using std::endl;

class Point {
public:
    Point(){
        cout << "Point()" << endl;
    }

    Point(int x)
    : _ix(x)
    , _iy(100)
    {
        cout << "Point(int)" << endl;
    }

    //初始化列表的形式,严格意义上的初始化
    Point(int x,int y)
    : _ix(x)
    , _iy(y)
    {
        cout << "Point(int,int)" << endl;
    }

    Point(const Point & rhs)
    : _ix(rhs._ix)
    , _iy(rhs._iy)
    {
        cout << "Point(const Point &)" << endl;
    }

    ~Point(){
        cout << "~Point()" << endl;
    }

	void print()
	{
		cout << "(" << _ix 
            << "," << _iy
			<< ")" << endl;
	}
private:
	int _ix = 100;//C++11之后允许的
	int _iy = 200;
};

void test0()
{
    /* int a; */
    /* int b = 1; */
    /* cout << a << endl; */

	Point pt;//创建对象时就会自动调用构造函数
	pt.print();

    Point pt2(1,2);
    pt2.print();

    Point pt3(100);
    pt3.print();

}

void test1(){
    Point pt1(18,45);
    Point pt2 = pt1;
    pt2.print();
    cout << &pt1 << endl;
    cout << &pt2 << endl;

    Point pt3(pt1);
    pt3.print();
}

int main(void){
    test1();
    return 0;
}
